package com.baidu.controller;

import com.baidu.pojo.TbSeller;
import com.baidu.service.TbBrandService;
import com.baidu.service.TbGoodsService;
import com.baidu.service.TbItemCatService;
import com.baidu.service.TbTypeTemplateService;
import com.baidu.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 满天星斗
 * @version 1.0
 * @description: TODO
 * @date 2021/8/23 21:31
 */

@RestController
@CrossOrigin(origins = "*",allowedHeaders = "*")
public class TbGoodsController {

    @Autowired
    private TbGoodsService goodsService;

    @Autowired
    private TbItemCatService itemCatService;

    @Autowired
    private TbBrandService brandService;

    @Autowired
    private TbTypeTemplateService typeTemplateService;

    @PostMapping("/getGoodsPage")
    public ResultResponse getGoodsPage(Integer current,Integer size,String goodsName,Integer status){
        return  goodsService.getGoodsPage(current,size,goodsName,status);
    }

    @PostMapping("/delGoodsByIds")
    public ResultResponse delGoodsByIds(String ids){
        return  goodsService.delGoodsByIds(ids);
    }

    @PostMapping("/commitAudit")
    public ResultResponse commitAudit(Integer id){
        return  goodsService.commitAudit(id);
    }

    @PostMapping("/shieldGoodsById")
    public ResultResponse shieldGoodsById(Integer id){
        return  goodsService.shieldGoodsById(id);
    }

    @PostMapping("/getItemList")
    public ResultResponse getItemList(Integer parentId){
        return itemCatService.getItemList(parentId);
    }

    @PostMapping("/uploadImages")
    public ResultResponse uploadImages(MultipartFile file){
        return itemCatService.uploadImages(file);
    }

    @PostMapping("/delImages")
    public ResultResponse delImages(String file){
        return itemCatService.delImages(file);
    }

    @PostMapping("/getBrandList")
    public ResultResponse getBrandList(){
        return  ResultResponse.SUCCESS(brandService.getBaseMapper().selectList(null));
    }

    @PostMapping("/getTypeTemplateByTypeId")
    public ResultResponse getTypeTemplateByTypeId(Integer typeId){
        return  typeTemplateService.getTypeTemplateByTypeId(typeId);
    }


}
